<?php
require_once  '../classes/ConnectionDB.php';
require_once  '../classes/UtenteManager.php';
require_once  '../classes/ClasseManager.php';

$connection =ConnectionDB::getInstance()->connectToDB();
$username = $_GET['username'];
$result = ClasseManager::getInstance()->getClassiByUser($connection, $username);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <script type="text/javascript">
          function showStudenti(codiceClasse)
          {
              location.href='showStudentsByClasse.php?codiceClasse=' + codiceClasse;
          }
       </script>

    </head>
    <body>
        <table>
            <tr>
            <th>Classe</th>
            <th>Sezione</th>
            <th>Indirizzo</th>
            <th>Vedi studenti</th>
            </tr>
        
                   <?php
                $result->bind_result($codiceClasse, $classe,$sezione, $descrizione);
                while($result->fetch())
                {
                    echo '<tr>';
                    echo '<td>'.$classe.'°</td><td>' . $sezione .' </td><td>'. $descrizione . '</td><td><a href="javascript:showStudenti('. $codiceClasse. ')">Studenti</td>';
                    echo '</tr>';
                }
                ?>
        </table>
   
    </body>
</html>
